//https://leetcode.cn/problems/minimum-size-subarray-sum/
/*
1、子数组：必须要求连续，哭了
2、滑动窗口满足条件的滑
3、209. 长度最小的子数组:
*/
class Solution {

public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int i = 0 , min_length = INT_MAX,sum = 0, key = 0;
        for( int j = 0; j < nums.size(); j++ ){
            sum += nums[j];
            while(sum >= target){
                key =1;
                min_length = min(min_length , j - i + 1);
                sum -= nums[i++];
            }
        }
        if(key)
            return min_length;
        else
            return 0;
    }
};